<template>
    <div>
    <transition name="fold">
            
            <div class="detail" v-show="pageShow">
                <div class="icon" @click="close" ><i class="iconfont icon-close"></i></div> 
                <img class="imgcss" :src="imgUrl" v-if="imgUrl!=null" :onerror="defaultImg">
                <p class="title" ref="titleRef">{{title}}</p>
            </div>
    </transition>
              <!-- 模糊背景 -->
      <transition name="fade">
        <div class="background" @click="close" v-show="pageShow"></div>
      </transition>
            
     
    </div>
</template>
<script>
export default {
  data() {
    return {
      defaultImg: 'this.src="' + require("@/assets/img/logo.png") + '"',
      imgUrl: "",
      pageShow: false,
      title:""
    };
  },
  methods: {
    show(_imgurl,title) {
      this.imgUrl="";
      this.imgUrl = _imgurl;
      this.title = title;
      if(_imgurl==null&& title!=null){
        //动态修改字体大小
          this.$refs.titleRef.style.fontSize ="14px";
      }
      this.pageShow = true;
    },
    close() {
      this.pageShow = false;
    }
  }
};
</script>
<style lang="scss" scoped>
@import "~@/assets/scss/const.scss";
@import "~@/assets/scss/mixin.scss";
.icon{
    z-index: 10;
    right:  0;
    top: 0;
    i {
      color: #ffffff;
      font-size: 30px;
     
    }
}
.detail {
    position: fixed;
    z-index: 9999999;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.imgcss {
  max-width: 100%;

}
.title{
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  width: 100%;
  max-height: 70%;
  overflow-y: auto;
  text-align: center;
}
/* 模糊背景 */
.background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  z-index: 1000;
  opacity: 1;
  backdrop-filter: blur(10px);
  background-color: rgba(0, 0, 0, 0.8);
  &.fold-enter-active,
  &.fold-leave-active {
    transition: all 0.5s;
  }
  &.fold-enter,
  &.fold-leave-active {
    opacity: 0;
    background: rgba(7, 17, 27, 0.8);
  }
}
</style>


